﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace DoubleH.Utility.Update
{
    public class UpdateUtility
    {
        /// <summary>
        /// 更新全部软件/插件/扩展
        /// </summary>
        public void Init()
        {
        }
        /// <summary>
        /// 读取指定url文件信息进行相关的软件更新
        /// </summary>
        /// <param name="url"></param>
        public void Init(string url)
        {
        }

        private void Download()
        {
        }
        /// <summary>
        /// 查找 Update 目录是否存在 .rar 压缩文件,如果有则解压升级并删除 rar文件
        /// </summary>
        /// <returns></returns>
        public bool RefreshFile()
        {
            if (Directory.Exists(DoubleH.Utility.Configuration.AppDefines.updateDir))
                return false;

            string[] files = Directory.GetFiles(DoubleH.Utility.Configuration.AppDefines.updateDir, "*.rar");
            if (files.Length == 0)
                return false;

            StringBuilder cmd=new StringBuilder();
             cmd.Append("Taskkill /f /im POS.exe \r\n");
             cmd.Append("Taskkill /f /im DoubleH.exe \r\n");
             foreach(string str in files)
                 cmd.Append("Rar.exe e 

            return true;
        }
    }
}